import Cookies from 'js-cookie'

const TokenKey = 'token'

export function getToken () {
  if (process.env.NODE_ENV === 'development') {
    // return '%03%28%5C%22%05vT3%012UvS%60We%05x'
    return Cookies.get(TokenKey)
  } else {
    // return '%03%28%5D%23T%27W0UfQrUfUg%03%7E'
    return Cookies.get(TokenKey)
  }
}

export function setToken (token) {
  return Cookies.set(TokenKey, token, { expires: 30 })
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}

export function setCookie (name, token, exp = 30) {
  return Cookies.set(name, token, { expires: exp })
}

export function getCookie (name) {
  return Cookies.get(name)
}

export function removeCookie (name) {
  return Cookies.remove(name)
}
